package org.zkoss.zktc.core.groovy;

import groovy.lang.Binding;
import groovy.lang.GroovyShell;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Test().test2();
	}

	public void test1(){
		Binding binding = new Binding();
		binding.setVariable("foo", new Integer(2));
		GroovyShell shell = new GroovyShell(binding);

		Object value = shell.evaluate("println 'Hello World!'; x = 123; return foo * 10");
		assert value.equals(new Integer(20));
		assert binding.getVariable("x").equals(new Integer(123));
	}
	
	public void test2(){
		
		Binding binding = new Binding();
		binding.setVariable("foo", new Integer(2));
		binding.setVariable("driver", "abcd");
		Engine engine = new Engine(binding);
		Object value;
		try {
			value = engine.execute("println 'Hello World! >>'+driver; x = 123; return foo * 10");
			System.out.println(">>"+value);
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
